<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>应用管理</title>
<link href="styles/general.css" rel="stylesheet" type="text/css" /><link href="styles/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/common.js"></script>
     <script type="text/javascript" src="js/sorttable.js"></script>
    <script src="js/utils.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/jquery/uploadify/jquery.min.js"></script>
	

<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dojo/resources/dojo.css" />
	<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dijit/themes/tundra/tundra.css" />
	<script src="http://ajax.pupkk.com/dojo/1.7.5/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
    <script type="text/javascript">
		dojo.require("dojo.parser");
		dojo.require("dijit.form.DateTextBox");
		dojo.require("dijit.form.FilteringSelect");
		function appversiondel(type,id){
			window.location.href="appversion_save.do?type="+type+"&model.id="+id;
		}
		function appversionshow(type,id,appnumber)
		{
			var cpid = document.getElementById("cpid").value;
			var categoryparentid = document.getElementById("categoryparentid").value;
			var appName = document.getElementById("appName").value;
			window.location.href="appversion_show.do?type="+type+"&model.id="+id+"&app.appnumber="+appnumber+"&cpid="+cpid+"&categoryparentid="+categoryparentid+"&appName="+appName;
		}
		function offonline(id,appstatus)
		{
			$.get("appversion_saveoffonline.do?type=offonline&model.id="+id+"&model.appstatus="+appstatus, 
           function(data) 
           { 
              document.getElementById("appstatusdiv").innerHTML=data;
           });
		}
		function goback()
		{
			var cpid = document.getElementById("cpid").value;
			var categoryparentid = document.getElementById("categoryparentid").value;
			var appName = document.getElementById("appName").value;
			window.location.href="app_list.do?cpid="+cpid+"&categoryparentid="+categoryparentid+"&appName="+appName;
		}
		function handOut(url){
			document.getElementById("msgDiv").innerHTML="";
			var sWidth, sHeight;
		    sWidth  = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth); 
		    sHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 
		    var bgObj = document.getElementById("bgDiv"); 
		    bgObj.style.position = "absolute";
		    bgObj.style.top = "0";
		    bgObj.style.background = "#817977";
		    bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=40,finishOpacity=60)";
		    bgObj.style.opacity = "0.4";
		    bgObj.style.left = "0";
		    bgObj.style.width = sWidth + "px";
		    bgObj.style.height = sHeight + "px";
		    bgObj.style.zIndex = "10000"; 

		    var msgObj = document.getElementById("msgDiv");
		    msgObj.style.position = "absolute";
		    msgObj.style.left = "40%";
		    msgObj.style.top = "20%";
		    msgObj.style.right = "10%";
		    msgObj.style.marginLeft = "-300px";
		    msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
		    msgObj.style.lineHeight = "25px";
		    msgObj.style.zIndex = "10001";
		    msgObj.style.display="";
		    bgObj.style.display="";
		    $.get(url,function(data){
		    	 document.getElementById("msgDiv").innerHTML=data;
		    });
		}
		function channleSub(){
			var channelids="",
				appversionId = $("#c_appversionId").val(),
				flag=false;
			$.each($("input[name=c_channelid]:checked"),function(i,item){
				channelids+=$(item).val()+",";
				flag=true;
			});
			if(!flag){
				alert("请勾选渠道信息！！");
				return;
			}
			$.get("appversion_channellist.do?type=save&model.id="+appversionId+"&channelids="+channelids,function(data){
				alert("分发成功,请前往渠道包管理界面更新相关信息！！");
				closechannelapp();
			});
		}
		function closechannelapp(){
			$("#bgDiv,#msgDiv").hide();
		}
	</script>
</head>

<body>
<h1>
        <span class="action-span"><a href="javascript:void(0);" onclick="appversionshow('insert','-1','<s:property value="app.appnumber"/>')">添加应用版本</a></span> 
        
        <span
            class="action-span1"><a href="mainframe.jsp">
                首页</a> </span><span id="search_id" class="action-span1">- 应用版本管理(
                CP：<s:property value="cp.cpName"/>&nbsp;&nbsp;&nbsp;&nbsp;
                	应用名称：<s:property value="app.appname"/>&nbsp;&nbsp;&nbsp;&nbsp;
                	类别：<s:iterator value="caplist">
						    <s:if test="id.equals(app.categoryparentid)"><s:property value="categoryName" /></s:if>
						    <s:if test="id.equals(app.categoryid)">[<s:property value="categoryName" />]</s:if>
						</s:iterator>) </span>
    </h1>
    <input name="cpid" type="hidden" id="cpid"  value="<s:property value="cpid"/>"/>
    <input name="categoryparentid" type="hidden" id="categoryparentid"  value="<s:property value="categoryparentid"/>"/>
    <input name="appName" type="hidden" id="appName"  value="<s:property value="appName"/>"/>
   <!-- start ad menu list -->
    <div class="list-div" id="listDiv">
        <table width="100%" cellspacing="1" cellpadding="2" class="sortable" id="sortable">
            <tbody>
                <tr>
                    <th height="20">版本ID</th>
				    <th>版本名称</th>
				    <!--th>类别</th-->
				    <th>包名</th>
				    <!--th>版本</th>
				    <th>入口</th-->
				    <th>平台</th>
				    <th>计费点</th>
				    <th>状态</th>
				    <th style="padding-right: 30px"></th>
                </tr>
                <s:if test="list.size()>0">
  				<s:iterator value="list" status="i"> 
  					 <tr>
                            <td style="background-color: rgb(255, 255, 255);"><s:property value="appversionnumber"/></td>
                            <td style="background-color: rgb(255, 255, 255);"><s:property value="appname"/></td>
						    <!-- td style="background-color: rgb(255, 255, 255);">
						    <s:iterator value="caplist">
						    	<s:if test="id.equals(categoryparentid)"><s:property value="categoryName" /></s:if>
						    </s:iterator>
						    </td-->
						    <td style="background-color: rgb(255, 255, 255);"><s:property value="apppackage"/></td>
						    <!-- td style="background-color: rgb(255, 255, 255);"><s:property value="appversion"/></td-->
						    <td style="background-color: rgb(255, 255, 255);"><s:iterator value="terraceInfo.split(',')" var="ti"><s:property value="#ti" /><br /></s:iterator></td>
						     <td style="background-color: rgb(255, 255, 255);"><a href="javascript:void(0);" onclick="handOut('appversion_showapppoint.do?model.id=<s:property value="id" />&app.appnumber=<s:property value="app.appnumber" />');" >查看</a></td>
						    <!-- td style="background-color: rgb(255, 255, 255);"><s:property value="%{terraceIdsToName(provinceids, terraceNameList)}" />
						    </td -->
						     <!-- td style="background-color: rgb(255, 255, 255);"><s:property value="%{billingIdsToName(apppointids, appPointList)}" />
						    </td -->						    
						    <!-- td style="background-color: rgb(255, 255, 255);" style="display:none;"><s:property value="appentry"/></td -->
						    <td style="background-color: rgb(255, 255, 255);">
						    <div id="appstatusdiv">
						    <s:if test="appstatus==0"><a href="javascript:void(0);" onclick="offonline('<s:property value="id"/>','<s:property value="appstatus"/>')">正常</a>
						    </s:if><s:else><a href="javascript:void(0);" onclick="offonline('<s:property value="id"/>','<s:property value="appstatus"/>')">暂停</a></s:else>
						    </div>
						    </td>
						    <td align="center" style="background-color: rgb(255, 255, 255);">
						     <s:if test="isUpdate.equals('true')">
							     <a href="javascript:void(0);" onclick="appversionshow('update','<s:property value="id"/>','<s:property value="app.appnumber"/>')">
							     	<img height="16" width="16" border="0" src="img/icon_edit.gif" alt="编辑"></a>&nbsp;
							     <a href="javascript:void(0);" onclick="if(confirm('警告！！确定要删除吗？')){appversiondel('del','<s:property value="id"/>')}" >
									<img height="16" width="16" border="0" src="img/icon_trash.gif" alt="删除">
								 </a>
							</s:if>
							<s:else>
								<a href="javascript:void(0);" onclick="appversionshow('update','<s:property value="id"/>','<s:property value="app.appnumber"/>')">
									<img height="16" width="16" border="0" src="img/icon_view.gif" alt="查看">
								</a>   
							</s:else>
								<a href="javascript:void(0);" onclick="handOut('appversion_channellist.do?model.id=<s:property value="id" />');">
									<img height="16" width="16" border="0" src="img/icon_fenfa.png" alt="分发">
								</a>
							</td>
  					</tr>
  				</s:iterator>
  				</s:if>
  				<tr>
  					<td colspan="9" align="center"><input type="button" value=" 返回 " class="button" onclick="goback()"/></td>
  				</tr>
  </tbody>
  </table>
  </div>
 <!--Bottom开始-->
    <script language="JavaScript">

if (document.getElementById("listDiv"))
{
  document.getElementById("listDiv").onmouseover = function(e)
  {
    obj = Utils.srcElement(e);

    if (obj)
    {
      if (obj.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode;
      else if (obj.parentNode.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode.parentNode;
      else return;

      for (i = 0; i < row.cells.length; i++)
      {
        if (row.cells[i].tagName != "TH") row.cells[i].style.backgroundColor = '#eeeded';
      }
    }

  }

  document.getElementById("listDiv").onmouseout = function(e)
  {
    obj = Utils.srcElement(e);

    if (obj)
    {
      if (obj.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode;
      else if (obj.parentNode.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode.parentNode;
      else return;

      for (i = 0; i < row.cells.length; i++)
      {
          if (row.cells[i].tagName != "TH") row.cells[i].style.backgroundColor = '#FFF';
      }
    }
  }

}

    </script>
    
<div id="footer">
<br />
<s:property value="bottom"/></div>
    <!--Bottom结束-->
    <div id="msgDiv" style="display:none;"></div>
<div id="bgDiv" style="display:none;" onclick="closachannelapp();"></div>
</body>
</html>